package com.ys.controller.api.outer;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bo.util.DateUtil;
import com.ys.service.amazonorder.TcoDayAllService;
import com.ys.service.amazonorder.TcoDayCountryService;
import com.ys.service.amazonorder.TcoDayProductJPEUROPEService;
import com.ys.service.amazonorder.TcoDayProductJPNORTHService;
import com.ys.service.amazonorder.TcoDayProductJPService;
import com.ys.service.amazonorder.TcoDayProductJPSumService;
import com.ys.service.amazonorder.TcoDayRegionService;
import com.ys.service.amazonorder.TcoMonthAllService;
import com.ys.service.amazonorder.TcoMonthCountryService;
import com.ys.service.amazonorder.TcoMonthProductJPEUROPEService;
import com.ys.service.amazonorder.TcoMonthProductJPNORTHService;
import com.ys.service.amazonorder.TcoMonthProductJPService;
import com.ys.service.amazonorder.TcoMonthProductJPSumService;
import com.ys.service.amazonorder.TcoMonthProductService;
import com.ys.service.amazonorder.TcoMonthProductTypeService;
import com.ys.service.amazonorder.TcoMonthProductYPService;
import com.ys.service.amazonorder.TcoMonthProductYPSumService;
import com.ys.service.amazonorder.TcoMonthRegionService;
import com.ys.service.amazonorder.TcoYearAllService;
import com.ys.service.amazonorder.TcoYearCountryService;
import com.ys.service.amazonorder.TcoYearProductJPEUROPEService;
import com.ys.service.amazonorder.TcoYearProductJPNORTHService;
import com.ys.service.amazonorder.TcoYearProductJPService;
import com.ys.service.amazonorder.TcoYearProductJPSumService;
import com.ys.service.amazonorder.TcoYearProductService;
import com.ys.service.amazonorder.TcoYearProductTypeService;
import com.ys.service.amazonorder.TcoYearProductYPService;
import com.ys.service.amazonorder.TcoYearProductYPSumService;
import com.ys.service.business.TpAmazonShopService;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/outer/amazonShop")
public class ApiOuterAmazonShopController {

    @Autowired
    private TpAmazonShopService tpAmazonShopService;
	@Autowired
	private TcoYearAllService tcoYearAllService;
	@Autowired
	private TcoYearCountryService tcoYearCountryService;
	@Autowired
	private TcoYearProductService tcoYearProductService;
	@Autowired
	private TcoYearProductYPService tcoYearProductYPService;
	@Autowired
	private TcoYearProductJPService tcoYearProductJPService;
	@Autowired
	private TcoYearProductJPNORTHService tcoYearProductJPNORTHService;
	@Autowired
	private TcoYearProductJPEUROPEService tcoYearProductJPEUROPEService;
	@Autowired
	private TcoYearProductYPSumService tcoYearProductYPSumService;
	@Autowired
	private TcoYearProductJPSumService tcoYearProductJPSumService;
	@Autowired
	private TcoYearProductTypeService tcoYearProductTypeService;
	@Autowired
	private TcoDayAllService tcoDayAllService;
	@Autowired
	private TcoDayCountryService tcoDayCountryService;
	@Autowired
	private TcoDayRegionService tcoDayRegionService;

	@Autowired
	private TcoDayProductJPService tcoDayProductJPService;
	@Autowired
	private TcoDayProductJPEUROPEService tcoDayProductJPEUROPEService;
	@Autowired
	private TcoDayProductJPNORTHService tcoDayProductJPNORTHService;
	@Autowired
	private TcoDayProductJPSumService tcoDayProductJPSumService;

	@Autowired
	private TcoMonthAllService tcoMonthAllService;
	@Autowired
	private TcoMonthCountryService tcoMonthCountryService;
	@Autowired
	private TcoMonthRegionService tcoMonthRegionService;
	@Autowired
	private TcoMonthProductService tcoMonthProductService;
	@Autowired
	private TcoMonthProductYPService tcoMonthProductYPService;
	@Autowired
	private TcoMonthProductJPService tcoMonthProductJPService;
	@Autowired
	private TcoMonthProductJPEUROPEService tcoMonthProductJPEUROPEService;
	@Autowired
	private TcoMonthProductJPNORTHService tcoMonthProductJPNORTHService;
	@Autowired
	private TcoMonthProductYPSumService tcoMonthProductYPSumService;
	@Autowired
	private TcoMonthProductJPSumService tcoMonthProductJPSumService;
	@Autowired
	private TcoMonthProductTypeService tcoMonthProductTypeService;

	@RequestMapping("/listAll")
    @ResponseBody
	public R listAll(HttpServletRequest request, HttpServletResponse response) {
		return tpAmazonShopService.listAll();
	}
	/*
	 * 更新销售数据表数据
	 */
	@RequestMapping("/addTpSaleDataSheet")
	@ResponseBody
	public void addTpSaleDataSheet() {
		Date now = new Date();

		String year = DateUtil.getYYYY(now);

		tcoYearAllService.addBatch(year);
		tcoYearCountryService.addBatch(year);
		tcoYearCountryService.addBatch(year);
		tcoYearProductService.addBatch(year);
		tcoYearProductYPService.addBatch(year);
		tcoYearProductYPSumService.addBatch(year);
		tcoYearProductJPService.addBatch(year);
		tcoYearProductJPEUROPEService.addBatch(year);
		tcoYearProductJPNORTHService.addBatch(year);
		tcoYearProductJPSumService.addBatch(year);
		tcoYearProductTypeService.addBatch(year);
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayAllService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayCountryService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayRegionService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayProductJPService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayProductJPNORTHService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayProductJPEUROPEService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addDays(now, i);
			String dayCurrent = DateUtil.getYYYY_MM_DD(dateCurrent);

			tcoDayProductJPSumService.addBatch(dayCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM(dateCurrent);

			tcoMonthAllService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthCountryService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthRegionService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductYPService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductYPSumService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductJPService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductJPNORTHService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductJPEUROPEService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductJPSumService.addBatch(monthCurrent);
		}
		for (int i = -14; i <= 0; i++) {
			Date  dateCurrent = DateUtil.addMonth(now, i);
			String monthCurrent = DateUtil.getYYYY_MM( dateCurrent);

			tcoMonthProductTypeService.addBatch(monthCurrent);
		}


	}

	
}
